#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int maxn = 2e5+5;
int n, k;
struct T{ // 使用结构体记录对应的数据关系
	int span;
	int rest;
	int sum;
	bool operator <(const T &t){ // 重载 < 根据 和 进行排序
		return sum < t.sum;
	}
}times[maxn];
void solve(){
	cin >> n >> k;
	for (int i=1;i <= n;i++) {
		cin >> times[i].span;
	}
	
	for (int i=1;i <= n;i++) {
		cin >> times[i].rest;
		times[i].sum = times[i].span + times[i].rest;
	}

	sort(times+1, times+1+n); 
	int sum = 0;
	for (int i=1; i <= n;i++) {
		sum += times[i].sum;
		if (sum > k) {
			cout << i << '\n';
			break;
		}
	}
}

signed main(){
	int t;
	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}
